package com.ytplayer.assets 
{
	import com.ytplayer.remote.Video;
	import com.ytplayer.screen.IResizable;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Jakub Wagner, J4W
	 */
	public class SongList extends Sprite implements IResizable
	{
		private var arrayOfVideos:Array;	
		
		private var holder:Sprite = new Sprite();
		
		public function SongList() 
		{
			addChild(holder);
		}
		
		public function updateList(_arrayOfVideos:Array):void 
		{
			arrayOfVideos = _arrayOfVideos;
			
			// delete all holder's children
			while (holder.numChildren) {
				holder.removeChildAt(0);
			}
			
			var i:uint = 0;
			for each(var video:Video in _arrayOfVideos) {
				var songItem:SongItem = new SongItem();
				songItem.video = video;
				songItem.width = 200;
				songItem.y = i * songItem.height;
				holder.addChild(songItem);
				i++;
			}
			
			holder.addEventListener(MouseEvent.CLICK, onHolderClick);
		}
		
		private function onHolderClick(e:MouseEvent):void 
		{
			
		}
		
		public function setSize(__width:Number, __height:Number, applyMargins:Boolean = true):void 
		{
			/*for (var i:int = 0; i < holder.numChildren; i++) 
			{
				var songItem:SongItem = holder.getChildAt(i) as SongItem;
			}*/
		}
		
	}

}